//
//  ImageBrowserView.h
//  etionUI
//
//  Created by WangJian on 14-2-17.
//  Copyright (c) 2014年 GuangZhouXuanWu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ImageBrowserViewCell.h"

@interface CImageBrowserLayout : UICollectionViewFlowLayout

@end

@interface CImageBrowserButtonItem : NSObject

@property (nonatomic, copy) NSString *title;
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) UIImage *selectedImage;

+ (CImageBrowserButtonItem *)itemWithTitle:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage;
- (CImageBrowserButtonItem *)initWithTitle:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage;

@end

@class CImageBrowserView;
@protocol CImageBrowserViewDelegate <NSObject>

@required
- (NSUInteger)numberOfImagesForImageBrowserView:(CImageBrowserView *)imageBrowserView;
- (id)imageBrowserView:(CImageBrowserView *)imageBrowserView cellInfoAtIndex:(NSUInteger)index;
- (void)imageBrowserViewNeedGetBack:(CImageBrowserView *)imageBrowserView;

@optional
- (void)imageBrowserView:(CImageBrowserView *)imageBrowserView didMoveToImageAtIndex:(NSUInteger)index;
- (void)imageBrowserView:(CImageBrowserView *)imageBrowserView didClickButtonItemAtIndex:(NSUInteger)index;

@end

@interface CImageBrowserView : UIView <UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, retain) UICollectionView *imageBrowserView;
@property (nonatomic, assign) NSUInteger curImageIndex;
@property (nonatomic, assign) id<CImageBrowserViewDelegate> delegate;

@property (nonatomic, retain) NSArray *buttonItems;
@property (nonatomic, readonly) CGFloat buttonTop;
@property (nonatomic, assign) BOOL showBtns;

- (void)showWithAnchorView:(UIView *)anchorView image:(UIImage *)image index:(NSUInteger)index fillStyle:(EImageFillStyle)fillStyle complete:(void (^)())complete;
- (void)showWithSupperView:(UIView *)supperView anchorView:(UIView *)anchorView image:(UIImage *)image index:(NSUInteger)index fillStyle:(EImageFillStyle)fillStyle complete:(void (^)())complete;
- (void)dismissWithAnchorView:(UIView *)anchorView fillStyle:(EImageFillStyle)fillStyle complete:(void (^)())complete;

- (void)showButtonItemsAnimated:(BOOL)animated complete:(void (^)(BOOL finished))complete;
- (void)hideButtonItemsAnimated:(BOOL)animated complete:(void (^)(BOOL finished))complete;

- (void)reloadImages;
- (UIImage *)imageAtIndex:(NSUInteger)index;
- (CImageBrowserViewCell *)cellAtIndex:(NSUInteger)index;
- (void)reloadImageAtIndex:(NSUInteger)index;

- (void)insertImageAtIndex:(NSUInteger)index;
- (void)deleteImageAtIndex:(NSUInteger)index;

@end

